<?php
/**
 * Created by PhpStorm.
 * User: yuyj
 * Date: 16-12-12
 * Time: 上午10:08
 */

namespace common\services\outstock;


use common\entities\outstock\MyscrmOutStockAttachmentEntity;
use common\repositories\outstock\OutStockAttachmentRepository;

class OutStockAttachmentService extends BaseService
{
    private $repository;

    public function __construct(OutStockAttachmentRepository $repository, $config = [])
    {
        $this->repository = $repository;

        return parent::__construct($config);
    }


    public function batchSave($orderId, array $models)
    {
        foreach ($models as &$model) {
            if (!$model instanceof MyscrmOutStockAttachmentEntity) {
                $model = (new MyscrmOutStockAttachmentEntity())->setAttribute($model);
            }
        }

        $this->repository->batchSave($orderId, $models);
    }

}